Next | Prev | Up | Top | Contents | Index

Using DSOs With C++

To make a DSO, build the C++ objects as you would normally:

CC -c
Then type:

CC -shared -o libmylib.so <list your objects here>
For example:

CC -shared -o libmylib.so a.o b.o c.o
The CC driver passes the -l and -L options to ld. However, the CC driver doesn't pass most ld options. If you want to specify other options, first determine the options that you must pass to ld via a direct invocation. These options include:

-init _main
-fini _fini
-hidden_symbol _main
-hidden_symbol _fini
-hidden_symbol __head
-hidden_symbol __endlink
Also, you must link /usr/lib/c++init.o. To add -delay_load -lbother, for example, the result is similar to the following:

ld -shared
-o libmylib.so
a.o b.o c.o
/usr/lib/c++init.o
-fini _fini
-hidden_symbol _main
-hidden_symbol _fini
-hidden_symbol __head
-hidden_symbol __endlink
-delay_load
-delay_load -lbother

Next | Prev | Up | Top | Contents | Index